#ifndef GAMEENGINE_GAMEPLAY_STATISTICS_STATISTICS_MANAGER_H
#define GAMEENGINE_GAMEPLAY_STATISTICS_STATISTICS_MANAGER_H

#include <GameEngine/Gameplay/gameplay_settings.h>

#include <GameEngine/Gameplay/Statistics/statistics.h>
#include <GameEngine/Core/string.h>

#include <QtCore/QObject>
#include <QtCore/QMap>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

//=================================================================================


//! Manages all the statistics associated to an item
/*!
 *  The statistics manager handles a collection of statistics associated to an object
 *  and provides methods to interact with these statistics. Especially, the manager
 *  allows to change the current and maximum values of the statistic, to lock the
 *  statistic in order to prevent it from being used (or conversely, unlock it), etc.
 *
 *  When a statistic of the collection is modified, the statistics_changed(name) signal
 *  is emited, with the name of the modified statistic provided as an argument of the
 *  signal.
 */
class _Gameplay_decl StatisticsManager : public QObject {
	Q_OBJECT

public:
	StatisticsManager();
	StatisticsManager(const StatisticsManager& rhs);
	StatisticsManager& operator=(const StatisticsManager& rhs);
	virtual ~StatisticsManager();

	bool has_stat(const GEString& name) const;
	bool add_stat(const GEString& name, Statistics& stat);
	bool remove_stat(const GEString& name);

	bool get_stat(const GEString& name, Statistics& stat) const;
	bool set_stat(const GEString& name, const Statistics& stat);
	bool lock_stat(const GEString& name);
	bool unlock_stat(const GEString& name);

	QList<GEString> stat_names() const;

signals:
	//! Signal called when one of the statistics of the statistics manager changes
	/*!
	 @param name The name of the modified statistics
	 */
	void statistics_changed(GEString name) const;

private:
	//! Collection of statistics
	QMap<GEString,Statistics> stats_;
};

//========================================================


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
